//
//  QLMUserHeaderView.m
//  Xiaomakuaixiu
//
//  Created by 龚碧容 on 2017/10/6.
//  Copyright © 2017年 hwd. All rights reserved.
//

#import "QLMUserHeaderView.h"

@interface QLMUserHeaderView()

@end

@implementation QLMUserHeaderView

/*
// Only override drawRect: if you perform custom drawing.
// An empty implementation adversely affects performance during animation.
- (void)drawRect:(CGRect)rect {
    // Drawing code
}
*/
- (instancetype)initWithFrame:(CGRect)frame{
    self = [super initWithFrame:frame];
    if (self) {
        [self _creatMainUI];
    }
    return self;
}

- (void)_creatMainUI{
    
    if (!_aBackImaView) {
        _aBackImaView=[[UIImageView alloc] init];
        _aBackImaView.backgroundColor=[UIColor redColor];
        _aBackImaView.frame=CGRectMake(0, 0, kScreen_width, 245*(kScreen_width/359));
        [self addSubview:_aBackImaView];
        
        CAGradientLayer *layer = [CAGradientLayer new];
        layer.colors=@[(__bridge id)UIColorFromRGB(0xf5f5f5).CGColor,(__bridge id)UIColorFromRGB(0xc1c1c1).CGColor];
        layer.startPoint = CGPointMake(0.5, 0);
        layer.endPoint = CGPointMake(0.5, 1);
        layer.frame = self.bounds;
        [_aBackImaView.layer addSublayer:layer];
    }
    
    if (!_vipBackImaView) {
        _vipBackImaView=[[UIImageView alloc] init];
        _vipBackImaView.image=[UIImage imageNamed:@"wdl"];
        _vipBackImaView.frame=CGRectMake(0, 20+20, kScreen_width, 225*(kScreen_width/359));
        [self addSubview:_vipBackImaView];
    }
    
    if (!_settingButton) {
        _settingButton=[UIButton buttonWithType:UIButtonTypeCustom];
        _settingButton.frame=CGRectMake(kScreen_width-18-18, 22, 18, 18);
        _settingButton.backgroundColor=[UIColor clearColor];
        [_settingButton setBackgroundImage:[UIImage imageNamed:@"shezhi"] forState:UIControlStateNormal];
        [self addSubview:_settingButton];
    }
    
    if (!_vipBtn) {
        _vipBtn=[UIButton buttonWithType:UIButtonTypeCustom];
        _vipBtn.frame=CGRectMake(0, 90+20, kScreen_width, 245*(kScreen_width/359)-90);
        [self addSubview:_vipBtn];
    }
    
    if(!_qrCodeButton){
        _qrCodeButton=[UIButton buttonWithType:UIButtonTypeCustom];
        _qrCodeButton.frame=CGRectMake(kScreen_width-50-36, 70, 36, 35);
        _qrCodeButton.backgroundColor=[UIColor clearColor];
        [_qrCodeButton setBackgroundImage:[UIImage imageNamed:@"ewm"] forState:UIControlStateNormal];
        [self addSubview:_qrCodeButton];
    }
    
    if (!_userheaderImaView) {
        _userheaderImaView=[[UIImageView alloc] init];
        _userheaderImaView.backgroundColor=[UIColor whiteColor];
        _userheaderImaView.image=[UIImage imageNamed:@"header"];
        _userheaderImaView.frame=CGRectMake(30, 40-5+20, 60, 60);
        _userheaderImaView.layer.masksToBounds=YES;
        _userheaderImaView.layer.cornerRadius=30.0f;
        [self addSubview:_userheaderImaView];
    }
    
    if (!_mynameBtn) {
        _mynameBtn = [[UIButton alloc]initWithFrame:CGRectMake(75+20, 47-5+20, 140, 21)];
        [_mynameBtn setTitle:@"请登录" forState:UIControlStateNormal];
        _mynameBtn.titleLabel.font = [UIFont systemFontOfSize:15.0f];
        _mynameBtn.contentHorizontalAlignment=UIControlContentHorizontalAlignmentLeft;
        [_mynameBtn setTitleColor:[UIColor whiteColor] forState:UIControlStateNormal];
        _mynameBtn.backgroundColor = [UIColor clearColor];
        [self addSubview:_mynameBtn];
    }
    
    if (!_myphoneLable) {
        _myphoneLable = [[UILabel alloc]initWithFrame:CGRectMake(75+20, 73-5+20, 180, 21)];
        _myphoneLable.text = @"";
        _myphoneLable.textAlignment=NSTextAlignmentLeft;
        _myphoneLable.font = [UIFont systemFontOfSize:13.0f];
        _myphoneLable.textColor=[UIColor whiteColor];
        _myphoneLable.backgroundColor = [UIColor clearColor];
        [self addSubview:_myphoneLable];
    }
    if (!_lineImaView) {
        _lineImaView=[[UIImageView alloc] init];
        _lineImaView.backgroundColor=[UIColor whiteColor];
        _lineImaView.frame=CGRectMake(75+20, _mynameBtn.frame.size.height+_mynameBtn.frame.origin.y+2.5, 160, 1);
        [self addSubview:_lineImaView];
    }
    //////////小马豆
    if (!_douBtn) {
        _douBtn=[UIButton buttonWithType:UIButtonTypeCustom];
        _douBtn.frame=CGRectMake(0, _vipBackImaView.frame.size.height+_vipBackImaView.frame.origin.y+3, kScreen_width/2, 50);
        _douBtn.backgroundColor=[UIColor whiteColor];//[UIColor colorWithRed:255/255.0 green:174/255.0 blue:0/255.0 alpha:1];
        [_douBtn setTitle:@"小马豆：0" forState:UIControlStateNormal];
        _douBtn.titleLabel.font=[UIFont systemFontOfSize:16];
        [_douBtn setTitleColor:[UIColor darkGrayColor] forState:UIControlStateNormal];
        [self addSubview:_douBtn];
    }
    
    if (!_youhuiBtn) {
        _youhuiBtn=[UIButton buttonWithType:UIButtonTypeCustom];
        _youhuiBtn.frame=CGRectMake(kScreen_width/2, _vipBackImaView.frame.size.height+_vipBackImaView.frame.origin.y+3, kScreen_width/2, 50);
        _youhuiBtn.backgroundColor=[UIColor whiteColor];//[UIColor colorWithRed:255/255.0 green:174/255.0 blue:0/255.0 alpha:1];
        [_youhuiBtn setTitle:@"优惠券：0" forState:UIControlStateNormal];
        _youhuiBtn.titleLabel.font=[UIFont systemFontOfSize:16];
        [_youhuiBtn setTitleColor:[UIColor darkGrayColor] forState:UIControlStateNormal];
        [self addSubview:_youhuiBtn];
    }
}

@end
